from django.db import models


# Create your models here.
class PurchaseM(models.Model):
    id = models.AutoField(primary_key=True)
    title = models.CharField(max_length=60)
    buyer = models.CharField(max_length=12)
    supplier = models.CharField(max_length=60)
    call = models.CharField(max_length=20)
    time = models.DateTimeField()

    def __str__(self):
        return self.supplier+str(self.time)

    class Meta:
        verbose_name = 'purchase main form'
        verbose_name_plural = 'purchase main form'


class PurchaseDetail(models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=60)
    number = models.FloatField()
    unit = models.CharField(max_length=6)
    price = models.DecimalField(max_digits=10, decimal_places=3)
    Mid = models.ForeignKey(PurchaseM, on_delete=models.Case)

    def __str__(self):
        return self.name

    class Meta:
        verbose_name_plural = 'purchase detail'

